;
if LineNr > 0 then
begin
Line := Page.GetString(LineNr);
PosIni := pos(txtTemp, Line);
SubLine := Copy(Line, PosIni + Length(txtTemp), Length(Line));
txtTemp := ')
0 then
begin
ShowMessage('No se ha encontrado ningún artículo por título.');
end else
begin
PickTreeClear;
PickTreeAdd('Resultados para "' + MovieName + '" en ' + Base + ':', '');
// buscamos los resultados
LineNr := 0;
while LineNr < Page.Count do
begin
SubLine := Page.GetString(LineNr);
txtTemp := '
';
PosFin := pos(txtTemp, SubLine);
DirURL := Base + Copy(SubLine, 1, PosFin - 1);
SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
txtTemp := '';
PosFin := pos(txtTemp, SubLine);
Title := Copy(SubLine, 1, PosFin - 1);
//ShowMessage(Title + '-->' + DirURL);
PickTreeAdd(Title, DirURL);
end;
LineNr := LineNr + 1;
end;
Page.Free;
if PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end;
end;
procedure AnalyzeMoviePage(Address: string);
var
Page: TStringList;
PosIni, PosFin: Integer;
dirBase: string;
txtTemp: string;
txtAux: string;
campo, valor: string;
LineNr: Integer;
Line, SubLine: string;
ImagenPeqSRC, ImagenURL, ImagenGrandeSRC: string;
Comentarios: string;
begin
//ShowMessage(Address);
SetField(fieldURL, Address);
Page := TStringList.Create;
Page.Text := StringReplace(GetPage(Address), ' ', #13#10);
// buscamos los campos
Comentarios := '';
ImagenPeqSRC := '';
ImagenURL := '';
ImagenGrandeSRC := '';
LineNr := 0;
while LineNr < Page.Count do
begin
SubLine := Page.GetString(LineNr);
//txtTemp := '';
txtTemp := ' ';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos(' | ', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if campo <> '' then SetField(fieldOriginalTitle, campo);
end;
txtTemp := '
';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos(':', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
LineNr := LineNr + 2;
SubLine := Page.GetString(LineNr);
txtTemp := '';
PosIni := pos(txtTemp, SubLine);
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos(' | ', txtAux);
valor := Copy(txtAux, 1, PosFin - 1);
if campo = 'AÑO' then SetField(fieldYear, valor);
if campo = 'NACIONALIDAD' then SetField(fieldCountry, valor);
if campo = 'DIRECTOR' then SetField(fieldDirector, valor);
if campo = 'INTÉRPRETES' then SetField(fieldActors, valor);
if campo = 'DURACION' then Comentarios := Comentarios + 'Duración: ' + valor + #13#10;
if campo = 'GUIÓN' then Comentarios := Comentarios + 'Guión: ' + valor + #13#10;
if campo = 'FOTOGRAFÍA' then Comentarios := Comentarios + 'Fotografía: ' + valor + #13#10;
if campo = 'MÚSICA' then Comentarios := Comentarios + 'Música: ' + valor + #13#10;
//ShowMessage(campo + '-->' + valor);
end;
txtTemp := '/cpp/albums/userpics/';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni, Length(SubLine));
PosFin := pos('" width="', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if ImagenPeqSRC = '' then ImagenPeqSRC := Base + campo;
end;
//this is the other directory I found
txtTemp := '/c/';
PosIni := pos(txtTemp, SubLine);
if ((PosIni > 0) and (ImagenPeqSRC = '')) then
begin
txtAux := Copy(SubLine, PosIni, Length(SubLine));
PosFin := pos('" width="', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if ImagenPeqSRC = '' then ImagenPeqSRC := Base + campo;
end;
//now the big image
txtTemp := 'pgrande.php?image_id=';
PosIni := pos(txtTemp, SubLine);
if ((PosIni > 0) and (ImagenURL = '')) then
begin
txtAux := Copy(SubLine, PosIni, Length(SubLine));
PosFin := pos('">', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if ImagenURL = '' then ImagenURL := Base + campo;
end;
txtTemp := '';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos(' | ', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if campo <> '' then SetField(fieldDescription, campo);
end;
LineNr := LineNr + 1;
end;
if Comentarios <> '' then SetField(fieldComments, Comentarios);
if ImagenURL <> '' then ImagenGrandeSRC := Base + AnalizaBigImagePage(ImagenURL);
//ShowMessage(ImagenGrandeSRC + '<--' + ImagenPeqSRC);
If (ImagenGrandeSRC <> '') or (ImagenPeqSRC <> '') then
begin
PickTreeClear;
PickTreeAdd('Imagenes para "' + MovieName + '" en ' + Base + ':', '');
If (ImagenPeqSRC <> '') then PickTreeAdd('Pequeña', ImagenPeqSRC);
If (ImagenGrandeSRC <> '') then PickTreeAdd('Grande', ImagenGrandeSRC);
if PickTreeExec(Address) then GetPicture(Address);
end;
Page.Free;
//DisplayResults;
end;
// bmicmic: Bucle Principal
begin
if CheckVersion(3,5,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
Input('Importar de ' + Base, 'Introduce el Titulo de la Pelicula:', MovieName);
AnalyzePage(BaseURL + UrlEncode(MovieName) + BaseURL2);
end else
ShowMessage('Este script necesita una versión superior de Ant Movie Catalog (al menos la version 3.5.0)');
end.
|